package com.aaa.controller;

import com.aaa.commen.domain.ReceiveInfo;
import com.aaa.commen.entity.Result;
import com.aaa.commen.query.RentOverdueQuery;
import com.aaa.service.IReceiveInfoService;
import com.aaa.service.IRentExpireAndOverdueService;
import com.aaa.service.IRentReceiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @PackageName: com.aaa.controller
 * @ClassName: RentOverdueController
 * @Description:
 * @author: 王嘉威
 * @Date: 2021/1/27 20:36
 */
@RestController
@RequestMapping("/rentOverdue")
public class RentOverdueController {
    @Autowired
    private IRentExpireAndOverdueService rentExpireAndOverdueService;

    @Autowired
    private IRentReceiveService rentReceiveService;

    @Autowired
    private IReceiveInfoService receiveInfoService;

    /**
     * 查询所有租金逾期信息
     * @return
     */
    @PostMapping("listOverdue")
    public Result listRentOverdue(@RequestBody RentOverdueQuery rentOverdueQuery){
        return rentExpireAndOverdueService.queryRentOverdue(rentOverdueQuery);
    }

    /**
     * 收缴已逾期的租金，并将其添加到租金已收缴信息表内
     * @return
     */
    @PostMapping("insertOverdueRent")
    public Result saveRentReceiveInfo(@RequestBody Map<String,String> map){
        return rentReceiveService.insertRentReceive(map);
    }

    /**
     * 查询某个合同所有已收取详细租金信息
     * @param contractId
     * @return
     */
    @GetMapping("listReceiveInfo")
    public Result listReceiveInfo(String contractId){
        return receiveInfoService.queryReceiveInfo(contractId);
    }

    /**
     * 根据发票号删除目标合同的某条租金信息
     * @param invoiceId
     * @return
     */
    @DeleteMapping("delReceiveInfo")
    public Result deleteReceiveInfo(int invoiceId){
        return receiveInfoService.deleteReceiveInfo(invoiceId);
    }

    /**
     * 修改某合同的租金收取信息
     * @param receiveInfo
     * @return
     */
    @PutMapping("editReceiveInfo")
    public Result editReceiveInfo(@RequestBody ReceiveInfo receiveInfo){
        return receiveInfoService.updateReceiveInfo(receiveInfo);
    }
}
